<template>
  <div class="sys_body">
    <div class="table_cont">
      <el-row type="flex" justify="center">
        <el-col :span="24">
          <el-tabs class="elTabs" v-model="activeName">
            <el-tab-pane
              v-for="(item, index) in tabs_list"
              :key="index"
              :label="item.name"
              :name="item.id"
            >
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-row>
    </div>

    <div class="form_cont">
      <el-row type="flex" justify="center">
        <el-col :span="24">
          <el-form
            :inline="true"
            :model="sys_form"
            :label-width="'170px'"
            class="sys_class"
          >
            <!-- 系统配置 -->
            <template v-if="activeName == '1'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">基础设置</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="站点名称">
                    <el-input v-model="sys_form['site.name']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="站点链接">
                    <el-input v-model="sys_form['site.link']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="上传基础路径">
                    <el-input v-model="sys_form['system.base_upload_path']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="陪跑银行">
                    <el-input v-model="sys_form['peipao.banks']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="小程序扫码处理页面">
                    <el-input v-model="sys_form['system.handle_scan_page']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="普通扫码处理页面">
                    <el-input
                      v-model="sys_form['system.handle_scan_page_normal']"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="提现金额">
                    <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px">
                      <el-input
                        class="input_center"
                        v-model="sys_form['system.withdraw_min_amount']"
                      >
                        <div class="unit_class" slot="prefix">最低</div>
                        <div class="unit_class" slot="suffix">元</div>
                      </el-input>
                      <el-input
                        class="input_center"
                        v-model="sys_form['system.withdraw_max_amount']"
                      >
                        <div class="unit_class" slot="prefix">最高</div>
                        <div class="unit_class" slot="suffix">元</div>
                      </el-input>
                    </div>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用审核状态">
                    <el-radio v-model="sys_form['system.is_audit']" :label="true"
                      >审核中</el-radio
                    >
                    <el-radio v-model="sys_form['system.is_audit']" :label="false"
                      >非审核中</el-radio
                    >
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="手动转账提现扣除比例">
                    <el-input v-model="sys_form['system.withdraw.manual_withdraw_deduction_rate']">
                      <div class="unit_class" slot="suffix">%</div>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="支付宝提现扣除比例">
                    <el-input v-model="sys_form['system.withdraw.alipay_withdraw_deduction_rate']">
                      <div class="unit_class" slot="suffix">%</div> 
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="微信提现扣除比例">
                    <el-input v-model="sys_form['system.withdraw.wechat_withdraw_deduction_rate']">
                      <div class="unit_class" slot="suffix">%</div> 
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="灵活用工提现扣除比例">
                    <el-input v-model="sys_form['system.withdraw.flexible_withdraw_deduction_rate']">
                      <div class="unit_class  " slot="suffix">%</div>
                    </el-input>
                  </el-form-item>
                </el-col>
               
                <el-col>
                  <div class="form_title">价格设置</div>
                </el-col>

                 <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="大数据查询最低价格">
                    <el-input v-model="sys_form['big_query.min_price']">
                      <div class="unit_class" slot="suffix">元</div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="大数据查询初始价格">
                    <el-input v-model="sys_form['big_query.default_price']">
                      <div class="unit_class" slot="suffix">元</div>
                    </el-input>
                  </el-form-item>
                </el-col>

               
                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="大数据查询最高价格">
                    <el-input v-model="sys_form['big_query.max_price']">
                      <div class="unit_class" slot="suffix">元</div>
                    </el-input>
                  </el-form-item>
                </el-col>

                
              </el-row>
            </template>

            <!--协议设置-->
            <template v-if="activeName == '2'">
              <el-row type="flex" justify="center" style="margin-top: 20px">
                <el-col :span="16">
                  <h4 class="xy_class">用户协议</h4>
                  <Tinymce :height="300" v-model="sys_form['site.agreement_user']" />
                </el-col>
              </el-row>

              <el-row type="flex" justify="center" style="margin-top: 20px">
                <el-col :span="16">
                  <h4 class="xy_class">隐私政策</h4>
                  <Tinymce :height="300" v-model="sys_form['site.agreement_privacy']" />
                </el-col>
              </el-row>

              <el-row type="flex" justify="center" style="margin-top: 20px">
                <el-col :span="16">
                  <h4 class="xy_class">结算协议</h4>
                  <Tinymce
                    :height="300"
                    v-model="sys_form['site.agreement_settlement']"
                  />
                </el-col>
              </el-row>
            </template>

            <!--阿里云 OSS-->
            <template v-if="activeName == '3'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">阿里云 OSS</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="密钥Id">
                    <el-input v-model="sys_form['aliyun_oss.accesskey_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="密钥Secret">
                    <el-input
                      v-model="sys_form['aliyun_oss.accesskey_secret']"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="节点">
                    <el-input v-model="sys_form['aliyun_oss.endpoint']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="存储空间">
                    <el-input v-model="sys_form['aliyun_oss.bucket']"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>

            <!--阿里云短信-->
            <template v-if="activeName == '4'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">阿里云短信</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="密钥Id">
                    <el-input v-model="sys_form['aliyun_sms.accesskey_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="密钥Secret">
                    <el-input
                      v-model="sys_form['aliyun_sms.accesskey_secret']"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="签名名称">
                    <el-input v-model="sys_form['aliyun_sms.sign_name']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="模板Code">
                    <el-input v-model="sys_form['aliyun_sms.template_code']"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>

            <!--微信设置-->
            <template v-if="activeName == '5'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">公众号</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AppId">
                    <el-input v-model="sys_form['wechat.app_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AppSecret">
                    <el-input v-model="sys_form['wechat.secret']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="Token">
                    <el-input v-model="sys_form['wechat.token']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AESKey">
                    <el-input v-model="sys_form['wechat.aes_key']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col>
                  <div class="form_title">小程序</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AppId">
                    <el-input v-model="sys_form['wechat_mini.app_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AppSecret">
                    <el-input v-model="sys_form['wechat_mini.secret']"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>

            <!--支付设置-->
            <template v-if="activeName == '6'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">支付宝</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用ID">
                    <el-input v-model="sys_form['alipay.app_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用私钥">
                    <el-input
                      class="file_input"
                      v-model="sys_form['alipay.app_secret.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="(e) => upload_change(e, 'alipay.app_secret')"
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('alipay.app_secret')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用公钥证书">
                    <el-input
                      class="file_input"
                      v-model="sys_form['alipay.app_public_cert_path.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'alipay.app_public_cert_path')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('alipay.app_public_cert_path')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="支付宝公钥证书">
                    <el-input
                      class="file_input"
                      v-model="sys_form['alipay.alipay_public_cert_path.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'alipay.alipay_public_cert_path')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('alipay.alipay_public_cert_path')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="支付宝根证书">
                    <el-input
                      class="file_input"
                      v-model="sys_form['alipay.alipay_root_cert_path.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'alipay.alipay_root_cert_path')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('alipay.alipay_root_cert_path')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="跳转地址">
                    <el-input v-model="sys_form['alipay.return_url']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="回调地址">
                    <el-input v-model="sys_form['alipay.notify_url']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col>
                  <div class="form_title">微信支付</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="商户Id">
                    <el-input v-model="sys_form['wechat_pay.mch_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="v2 API 秘钥">
                    <el-input v-model="sys_form['wechat_pay.v2_secret_key']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="v3 API 秘钥">
                    <el-input v-model="sys_form['wechat_pay.v3_secret_key']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="商户私钥">
                    <el-input
                      class="file_input"
                      v-model="sys_form['wechat_pay.private_key.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'wechat_pay.private_key')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('wechat_pay.private_key')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="商户证书">
                    <el-input
                      class="file_input"
                      v-model="sys_form['wechat_pay.certificate.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'wechat_pay.certificate')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('wechat_pay.certificate')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="回调地址">
                    <el-input v-model="sys_form['wechat_pay.notify_url']"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>

            <!--第三方集成-->
            <template v-if="activeName == '7'">
              <el-row :gutter="10">
                <el-col>
                  <div class="form_title">识别</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="阿里云 APPCODE">
                    <el-input v-model="sys_form['aliyun_ocr.appcode']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col>
                  <div class="form_title">岭南数科</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="ClientId">
                    <el-input v-model="sys_form['services.lnsk.client_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="私钥">
                    <el-input
                      class="file_input"
                      v-model="sys_form['services.lnsk.private_key.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="
                            (e) => upload_change(e, 'services.lnsk.private_key')
                          "
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('services.lnsk.private_key')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="BaseUrl">
                    <el-input v-model="sys_form['services.lnsk.base_url']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col>
                  <div class="form_title">扣子</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="AppId">
                    <el-input v-model="sys_form['coze.app_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用公钥指纹">
                    <el-input
                      v-model="sys_form['coze.public_key_fingerprint']"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="应用私钥">
                    <el-input
                      class="file_input"
                      v-model="sys_form['coze.private_key.ext']"
                      readonly
                    >
                      <div class="file_div" slot="append">
                        <el-upload
                          action
                          :http-request="(e) => upload_change(e, 'coze.private_key')"
                          :show-file-list="false"
                        >
                          <el-button type="text">上传文件</el-button>
                        </el-upload>
                        <el-button
                          type="text"
                          @click="delete_file_change('coze.private_key')"
                          >删除</el-button
                        >
                      </div>
                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="征信工作流id">
                    <el-input v-model="sys_form['coze.credit_workflow_id']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="流水工作流id">
                    <el-input
                      v-model="sys_form['coze.business_flow_workflow_id']"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col>
                  <div class="form_title">税票查询</div>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="税票标识">
                    <el-input v-model="sys_form['tax_invoice.slug']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="授权页面">
                    <el-input v-model="sys_form['tax_invoice.auth_link']"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                  <el-form-item label="报告页面">
                    <el-input v-model="sys_form['tax_invoice.report_link']"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>
          </el-form>
        </el-col>
      </el-row>

      <el-row type="flex" justify="center" style="margin-top: 20px">
        <el-col :span="24">
          <div class="update_btn">
            <el-button type="primary" @click="update_sys_fun">保存</el-button>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import {
  getSettings,
  saveSettings,
  uploadConfigFile,
  deleteConfigFile,
} from "@/api/user";
import Tinymce from "@/components/Tinymce";
export default {
  components: {
    Tinymce,
  },
  data() {
    return {
      activeName: "1",
      tabs_list: [
        { id: "1", name: "系统配置" },
        { id: "2", name: "协议" },
        { id: "3", name: "存储" },
        { id: "4", name: "短信" },
        { id: "5", name: "微信" },
        { id: "6", name: "支付" },
        { id: "7", name: "第三方集成" },
      ],
      sys_form: {
        // 站点名称
        "site.name": "",
        // 站点链接
        "site.link": "",

        // 上传基础路径
        "system.base_upload_path": "",
        // 小程序扫码处理页面
        "system.handle_scan_page": "",
        // 普通扫码处理页面
        "system.handle_scan_page_normal": "",
        // 应用审核状态（true审核中，false非审核中）
        "system.is_audit": "",
        //手动转账提现扣除比例
        "system.withdraw.manual_withdraw_deduction_rate":"",
        //支付宝提现扣除比例
        "system.withdraw.alipay_withdraw_deduction_rate":"",
        //微信提现扣除比例
        "system.withdraw.wechat_withdraw_deduction_rate":"",
        //灵活用工提现扣除比例
        "system.withdraw.flexible_withdraw_deduction_rate":"",
        //大数据查询最高价格
        "big_query.max_price":"",


        // 提现最低金额
        "system.withdraw_min_amount": "",
        // 提现最高金额
        "system.withdraw_max_amount": "",

        // 大数据查询初始价格
        "big_query.default_price": "",
        // 大数据查询初始分佣比例
        "big_query.default_commission": "",

        // 陪跑银行
        "peipao.banks": "",

        // oss
        // 阿里云 OSS 密钥Id
        "aliyun_oss.accesskey_id": "",
        // 阿里云 OSS 密钥Secret
        "aliyun_oss.accesskey_secret": "",
        // 阿里云 OSS 节点
        "aliyun_oss.endpoint": "",
        // 阿里云 OSS 存储空间
        "aliyun_oss.bucket": "",

        // sms
        // 阿里云短信密钥Id
        "aliyun_sms.accesskey_id": "",
        // 阿里云短信密钥Secret
        "aliyun_sms.accesskey_secret": "",
        // 阿里云短信签名名称
        "aliyun_sms.sign_name": "",
        // 阿里云短信模板Code
        "aliyun_sms.template_code": "",

        // 阿里云 OCR APPCODE
        "aliyun_ocr.appcode": "",

        // 陪跑公众号
        // 公众号AppId
        "wechat.app_id": "",
        // 公众号AppSecret
        "wechat.secret": "",
        // 公众号Token
        "wechat.token": "",
        // 公众号AESKey
        "wechat.aes_key": "",

        // 领跑市集小程序
        // 小程序AppId
        "wechat_mini.app_id": "",
        // 小程序AppSecret
        "wechat_mini.secret": "",

        // 微信支付
        // 商户Id
        "wechat_pay.mch_id": "",
        // v2 API 秘钥
        "wechat_pay.v2_secret_key": "",
        // v3 API 秘钥
        "wechat_pay.v3_secret_key": "",
        // 商户私钥
        "wechat_pay.private_key": "",
        // 商户私钥(显示)
        "wechat_pay.private_key.ext": "",
        // 商户证书
        "wechat_pay.certificate": "",
        // 商户证书(显示)
        "wechat_pay.certificate.ext": "",
        // 支付回调地址
        "wechat_pay.notify_url": "",

        // 岭南数科
        // 岭南数科ClientId
        "services.lnsk.client_id": "",
        // 岭南数科私钥
        "services.lnsk.private_key": "",
        // 岭南数科私钥(显示)
        "services.lnsk.private_key.ext": "",
        // 岭南数科BaseUrl
        "services.lnsk.base_url": "",

        // 扣子
        // 扣子AppId
        "coze.app_id": "",
        // 应用公钥指纹
        "coze.public_key_fingerprint": "",
        // 应用私钥
        "coze.private_key": "",
        // 应用私钥(显示)
        "coze.private_key.ext": "",
        // 征信工作流id
        "coze.credit_workflow_id": "",
        // 流水工作流id
        "coze.business_flow_workflow_id": "",

        // 税票
        // 税票标识
        "tax_invoice.slug": "",
        // 税票授权页面
        "tax_invoice.auth_link": "",
        // 税票报告页面
        "tax_invoice.report_link": "",

        // 支付宝支付
        // 应用 Id
        "alipay.app_id": "",

        // 应用私钥
        "alipay.app_secret": "",
        // 应用私钥(显示)
        "alipay.app_secret.ext": "",

        // 应用公钥证书
        "alipay.app_public_cert_path": "",
        // 应用公钥证书(显示)
        "alipay.app_public_cert_path.ext": "",

        // 公钥证书
        "alipay.alipay_public_cert_path": "",
        // 公钥证书(显示)
        "alipay.alipay_public_cert_path.ext": "",

        // 支付宝根证书
        "alipay.alipay_root_cert_path": "",
        // 支付宝根证书(显示)
        "alipay.alipay_root_cert_path.ext": "",

        // 跳转 url
        "alipay.return_url": "",
        // 回调 URL
        "alipay.notify_url": "",
      },
    };
  },
  mounted() {
    this.getSettings_fun();
  },
  methods: {
    delete_file_change(config_key) {
      deleteConfigFile({ config_key }).then((res) => {
        this.$message.success("删除成功");
        this.getSettings_fun();
      });
    },

    async upload_change(file, configKey) {
      const categoryList = [
        { c_key: "alipay", category: "alipay" },
        { c_key: "wechat_pay", category: "weixinpay" },
        { c_key: "lnsk", category: "ling_nan_shu_ke" },
        { c_key: "coze", category: "coze" },
      ];

      let index = categoryList.findIndex((v) => configKey.indexOf(v.c_key) !== -1);
      // console.log('category对应下标为：',index)

      let formdata = new FormData();
      formdata.append("file", file.file);
      formdata.append("category", categoryList[index].category);
      formdata.append("file_name", file.file.name);
      formdata.append("config_key", configKey);
      uploadConfigFile(formdata).then((res) => {
        this.$message.success("设置成功");
        this.getSettings_fun();
      });
    },

    // 更新系统配置
    update_sys_fun() {
      let params = JSON.parse(JSON.stringify(this.sys_form));
      params["peipao.banks"] = params["peipao.banks"]
        ? params["peipao.banks"].split(",")
        : [];
      saveSettings(params).then((res) => {
        this.$message({
          message: "系统配置更新成功",
          type: "success",
        });
      });
    },

    getSettings_fun() {
      getSettings().then((res) => {
        if (res.data) {
          this.sys_form = res.data;
          this.sys_form["peipao.banks"] = res.data["peipao.banks"]
            ? res.data["peipao.banks"].join(",")
            : "";
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.sys_body {
  ::v-deep .table_cont {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 0 20px;
    box-sizing: border-box;
    .elTabs .el-tabs__item {
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #666060;
      height: 50px !important;
      line-height: 50px !important;
    }
    .el-tabs__header {
      margin: 0;
    }
    .el-tabs__item.is-active {
      color: #0569ff !important;
      font-weight: bold !important;
    }
    .el-tabs__nav-wrap::after {
      height: 0px !important;
    }

    .el-tabs__active-bar {
      background-color: #0569ff !important;
    }
  }

  .form_cont {
    margin-top: 20px;
    background: linear-gradient(0deg, #f9fafe 0%, #ffffff 100%);
    box-shadow: 0px 2px 8px 0px rgba(54, 131, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    .form_title {
      font-family: Microsoft YaHei;
      font-weight: 400;
      font-size: 14px;
      color: #000000;
      margin: 20px 0;
    }
    ::v-deep .sys_class {
      .unit_class {
        width: 30px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        font-size: 12px;
        color: #626466;
      }
      .el-form-item {
        margin-bottom: 15px;
        width: 100%;
      }
      .el-form-item__label {
        font-family: Microsoft YaHei;
        font-weight: 400;
        font-size: 14px;
        color: #626466;
      }
      .el-form-item__content {
        width: calc(100% - 170px);
        max-width: 500px;
      }
      .el-input__inner {
        height: 32px !important;
        line-height: 32px !important;
        background: #ffffff;
        border: 1px solid #c4c8cc;
        border-radius: 4px;
        color: #000000;
      }
      .input_center {
        .el-input__inner {
          text-align: center !important;
        }
      }
      .file_input {
        .el-input-group__append {
          background-color: transparent;
          color: #0084ff;
          vertical-align: middle;
          display: table-cell;
          border: none;
          border-radius: 0;
          padding: 0;
          white-space: nowrap;
        }
        .file_div {
          width: 100px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 0 20px;
          box-sizing: border-box;
          margin-left: 20px;
        }
        .el-input__inner {
          background: #eceef5;
        }
      }
    }
  }
  .xy_class {
    text-align: center;
  }
  .update_btn {
    display: flex;
    align-items: center;
    justify-content: center;
    .el-button--primary {
      width: 200px;
      height: 36px;
      background: #0569ff;
      border-radius: 6px;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #ffffff;
    }
  }
}
</style>
